#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "frts_app.h"
#include "nvs_flash.h"
#include "esp_system.h"
#include "esp_chip_info.h"
#include "esp_psram.h"
#include "esp_flash.h"
#include "esp_log.h"
#include "led.h"
#include "key.h"
#include "WiFi.h"

const char *basic = "basic";
/**
 * @brief       程序入口
 * @param       无
 * @retval      无
 */
void app_main(void)
{
    esp_err_t ret;
    uint32_t flash_size;
    esp_chip_info_t chip_info;

    ret = nvs_flash_init(); /* 初始化NVS */

    if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND)
    {
        ESP_ERROR_CHECK(nvs_flash_erase());
        ret = nvs_flash_init();
    }

    esp_flash_get_size(NULL, &flash_size); /* 获取FLASH大小 */

    esp_chip_info(&chip_info);
    ESP_LOGI(basic, "内核：cup数量%d", chip_info.cores);                    /* 获取CPU内核数并显示 */
    ESP_LOGI(basic, "FLASH size:%ld MB flash", flash_size / (1024 * 1024)); /* 获取FLASH大小并显示 */
    ESP_LOGI(basic, "PSRAM size: %d bytes", esp_psram_get_size());          /* 获取PARAM大小并显示 */

    led_init();      /* 初始化LED */
    wifi_SmartAirconfig_sta();
    frts_app_init(); /* 初始化FreeRTOS应用 */

    while (1)
    {
        LED(0);
        vTaskDelay(70);
        LED(1);
        vTaskDelay(1930);
    }
}
